<template>
  <div class="child1">
    这是child1组件
    <!-- <h1>这是child1---{{ child1Value }}</h1> -->
    <h1>这是child1---{{ $store.state.count }}</h1>
    <el-button @click="child1Add">child1自增</el-button>
  </div>
</template>

<style scoped lang="scss">
.child1 {
  width: 300px;
  height: 200px;
  border: 2px solid blue;
}
</style>

<script>
export default {
  methods: {
    child1Add() {
      // this.$emit('update:child1Value',this.child1Value+1);
      this.$store.commit("addCount");
    },
  },
  // 父组件到子组件传参
  //1.定义props接收参数
  //2.在父组件中传递参数
  props: {
    child1Value: {
      type: Number,
      default: 0,
    },
  },
  data() {
    return {};
  },
};
</script>